﻿package mortal.game.view.chat.chatPrivate
{
    import __AS3__.vec.*;
    import com.mui.containers.*;
    import com.mui.containers.globalVariable.*;
    import flash.display.*;
    import mortal.game.view.chat.chatPanel.*;

    public class ChatPrivatePanel extends GBox
    {
        private var _spMessageVector:Vector.<ChatTimeItem>;
        private var _maxItem:int;

        public function ChatPrivatePanel(param1:int = 30)
        {
            this._maxItem = param1;
            this._spMessageVector = new Vector.<ChatTimeItem>;
            super.direction = GBoxDirection.VERTICAL;
            super.verticalGap = 6;
            return;
        }// end function

        public function addChatItem(param1:ChatItem, param2:ChatData) : void
        {
            var _loc_3:* = new ChatTimeItem(param1, param2);
            this.addChild(_loc_3);
            this._spMessageVector.push(_loc_3);
            if (this._spMessageVector.length > this._maxItem)
            {
                _loc_3 = this._spMessageVector.shift();
                this.removeChild(_loc_3);
                _loc_3.dispose();
            }
            this.validateNow();
            return;
        }// end function

        override public function validateNow() : void
        {
            updateDisplayList();
            super.validateNow();
            return;
        }// end function

        override public function get height() : Number
        {
            var _loc_4:DisplayObject = null;
            var _loc_5:int = 0;
            var _loc_6:ChatTimeItem = null;
            var _loc_1:Number = 0;
            var _loc_2:int = 0;
            var _loc_3:* = this._spMessageVector.length;
            while (_loc_2 < _loc_3)
            {
                
                _loc_6 = this._spMessageVector[_loc_2];
                _loc_1 = _loc_1 + _loc_6.height;
                _loc_2++;
            }
            return _loc_1 + 10 + verticalGap * (this._spMessageVector.length - 1);
        }// end function

        public function reset() : void
        {
            this._spMessageVector = new Vector.<ChatTimeItem>;
            var _loc_1:* = this.numChildren - 1;
            while (_loc_1 >= 0)
            {
                
                this.removeChildAt(_loc_1);
                _loc_1 = _loc_1 - 1;
            }
            return;
        }// end function

    }
}
